﻿using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Mail;
using System.Text;

namespace Method.Mail
{
    public static class SendMail
    {
        /// <summary>
        /// 发送邮件
        /// </summary>
        /// <param name="gmail"></param>
        /// <returns>返回验证码</returns>
        public static string Send(string gmail)
        {
            //获取验证码
            var code = CreateCode.create();
            MailMessage mail = new MailMessage();
            mail.From = new MailAddress("3154287655@qq.com");
            mail.To.Add(new MailAddress(gmail));
            mail.Subject = "来自遥远的呼唤";
            mail.Body = "您的验证码是 : " + code;
            SmtpClient client = new SmtpClient("smtp.qq.com");
            client.EnableSsl = true;
            client.Credentials = new NetworkCredential("3154287655@qq.com", "djwismotljsudfgd");
            client.Send(mail);
            return code;
        }
    }
}
